<?php

class Admin_OpenId_ServerWebResponseView extends BlogAdminBaseView
{
	public function executeLhtml(AgaviRequestDataHolder $rd)
	{
	    require_once 'Auth/OpenID/Server.php';
	    
		//$this->setupHtml($rd);
        $openid_server = $this->getAttribute('openid_server');
        $openid_request = $this->getAttribute('openid_request');
        
		//$this->setAttribute('_title', 'OpenId.Server');
		$openid_response = $openid_server->handleRequest($openid_request);
		$web_response = $openid_server->encodeResponse($openid_response);
		$agavi_response = $this->getResponse();
		
		
		if ($web_response->code != AUTH_OPENID_HTTP_OK) {
            $agavi_response->setHttpStatusCode($web_response->code);
		}
		
        foreach ($web_response->headers as $k => $v) {
            $agavi_response->setHttpHeader($k, $v);
        }
        $agavi_response->setHttpHeader('Connection', 'close');
        return $web_response->body;
	}
}

?>
